#!/bin/bash

customNum=100
orderNum=200

if [[ -f tmp ]];then
    rm tmp
fi
if [[ -f custom.sql ]];then
    rm custom.sql
fi
for i in `seq $customNum`; do
  uuid=$(uuidgen)
  echo $uuid >> tmp
done

## custom.sql文件为向t_custom表插入数据的sql
awk -v LINE_NUM=$customNum 'BEGIN{
  srand(); 
  for(i=1;i<=LINE_NUM;i++) {
    a[i]=int(rand()*10000%100);
  } 
}{
  print "insert into t_custom(custom_id,name,uuid,age) values ("NR",'\''张"NR"'\'','\''"$1"'\'',"a[NR]");"
}' tmp > custom.sql


## order.sql文件为向t_order表插入数据的sql
echo "" | awk -v ORDER_NUM=$orderNum -v CUSTOM_NUM=$customNum 'BEGIN{
  srand(); 
  for(i=1;i<=ORDER_NUM;i++) {
    money=int(rand()*10000%1000);
    customId=int(rand()*100000%CUSTOM_NUM+1);
    print "insert into t_order(custom_id,money) values ("customId","money");"
  } 
}' > order.sql